<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<load href="__PUBLIC__/js/jquery-1.9.1.min.js" />
<script>
$(function(){
	$("input[name='file']").change(function(){
		if($(this).val()==""){
			alert("请选择一个有效的文件上传!");	
		}else{
		    var formData = new FormData($("#uploadForm" )[0]);  
		    $.ajax({  
		         url: '{:U('jupload')}' ,  
		         type: 'POST',  
		         data: formData,  
		         async: false,  
		         cache: false,  
		         contentType: false,  
		         processData: false,  
		         success: function (returndata) {  
		        	 $(".loading").html("上传成功！"); 
		        	 alert(returndata); 
		         },  
		         error: function (returndata) {  
		             alert(returndata);  
		         }  
		    }); 	
		}
	})
})
</script>
</head>

<body>

<form id="uploadForm">  
     <h1 >测试通过Rest接口上传文件 </h1>   
     <p >上传文件： <input type ="file" name="file" /><div class="loading">正在上传</div></p>  
</form>


</body>
</html>
